package com.hcl.orm.sample;

import com.hcl.orm.core.executor.nativesql.NativeSqlExecutorFactory;
import com.hcl.orm.core.executor.nativesql.tablestruct.TableColumn;
import com.hcl.orm.core.executor.nativesql.tablestruct.TsSqlExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.List;

/**
 * @author hucl
 * @projectName hcl-orm
 * @description: 特殊原生SQL执行
 * @date 2021/8/1618:09
 */
public class NativeSqlSample {
    private static final Logger logger = LoggerFactory.getLogger(NativeSqlSample.class);
    private ConfigurableApplicationContext context;

    public NativeSqlSample(ConfigurableApplicationContext context) {
        this.context = context;
    }

    public void test() {
        NativeSqlExecutorFactory factory = this.context.getBean(NativeSqlExecutorFactory.class);
        List<TableColumn> columnList = factory.getExecutor(TsSqlExecutor.class)
                .getTableColumns("PRD_AGENCY");
        logger.info("获取表结构成功：" + columnList);
    }
}
